package com.share.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * author:caifan
 * date:2019/4/6
 */
@Component
public class MvcLogInterceptor implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器
        InterceptorRegistration registration = registry.addInterceptor(new LogInterceptor());
        //配置拦截路径
        registration.addPathPatterns("/**");
        //配置不拦截路径
        registration.excludePathPatterns("/static/**", "/template/**");
    }
}
